import pymysql

def log(func):
    def wrapper(sname):
        func(sname)
        connect = pymysql.connect(host='localhost',user='root',password='123456',port=3306,database='woniudb')
        cursor = connect.cursor()
        cursor.execute("insert into stustrg values (0,'{}')".format(sname))
        connect.commit()
        cursor.close()
        if connect:
            connect.close()
            print('连接已关闭')
        else:
            print('关闭连接失败')
    return wrapper